package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.LostClientRecord;
import cn.wolfcode.crm.mapper.LostClientRecordMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ILostClientRecordService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class LostClientRecordImpl implements ILostClientRecordService {
    @Autowired
    private LostClientRecordMapper lostRecordMapper;

    public void saveOrUpdate(LostClientRecord entity) {
            lostRecordMapper.insert(entity);
    }


    public PageResult query(QueryObject qo) {
        int count = lostRecordMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<LostClientRecord> lostRecords = lostRecordMapper.queryList(qo);
        return new PageResult(count, lostRecords);
    }
}
